import { useLocalStorage } from '@vueuse/core';

const KEY = 'USERID';

/**
 * 设置userId和获取userId
 * @returns
 */
export const useUserId = () => {
  const userIdStorage = useLocalStorage(KEY, '');

  // 获取userId
  const getUserId = () => userIdStorage.value;

  // 设置userId
  const setUserId  = (_userId: string) => (userIdStorage.value = _userId);

  const clearUserId  = () => (userIdStorage.value = '');

  return { setUserId , getUserId , clearUserId  };
};
